package com.hqd.ch03.v48.aop.framework.adapter;

import com.hqd.ch03.v48.aop.Advisor;
import com.hqd.ch03.v48.aop.BeforeAdvice;
import com.hqd.ch03.v48.aop.MethodBeforeAdvice;
import com.hqd.ch03.v48.aopalliance.aop.Advice;
import com.hqd.ch03.v48.aopalliance.intercept.MethodInterceptor;

public class MethodBeforeAdviceAdapter implements AdvisorAdapter {
    @Override
    public boolean supportsAdvice(Advice advice) {
        return advice instanceof BeforeAdvice;
    }

    @Override
    public MethodInterceptor getInterceptor(Advisor advisor) {
        MethodBeforeAdvice advice = (MethodBeforeAdvice) advisor.getAdvice();
        return new MethodBeforeAdviceInterceptor(advice);
    }
}
